﻿using System.Collections.Generic;
using System.Drawing;

namespace InfoPathHelpers.RepeatingTable.Paginator
{
    public class RepeatingTableDescription
    {
        public RepeatingTableDescription() 
        {
            Columns = new List<RepeatingTableColumnDescription>();
        }

        public RepeatingTableDescription(string xPath)
        {
            XPath = xPath;
            Columns = new List<RepeatingTableColumnDescription>();
        }

        public string XPath { get; set; }

        public List<RepeatingTableColumnDescription> Columns { get; private set; }

        public void AddColumn(string localName, int widthInPixels, bool isMultiLine)
        {
            Columns.Add(new RepeatingTableColumnDescription()
            {
                LocalName = localName,
                Width = widthInPixels,
                IsMultiLine = isMultiLine
            });
        }

        public void AddColumn(string localName, int widthInPixels, bool isMultiLine, double widthAdjust)
        {
            Columns.Add(new RepeatingTableColumnDescription()
            {
                LocalName = localName,
                Width = widthInPixels,
                IsMultiLine = isMultiLine,
                WidthAdjust = widthAdjust
            });
        }

        public void AddColumn(string localName, int widthInPixels, bool isMultiLine, Font font)
        {
            Columns.Add(new RepeatingTableColumnDescription()
            {
                LocalName = localName,
                Width = widthInPixels,
                IsMultiLine = isMultiLine,
                Font = font
            });
        }

        public void SetFontForAllColumns(Font font)
        {
            Columns.ForEach(x => x.Font = font);
        }

        public void SetFontForAllColumns(string fontFamily, float fontWeight)
        {
            Font Font = new System.Drawing.Font(fontFamily, fontWeight, System.Drawing.FontStyle.Regular);
            Columns.ForEach(x => x.Font = Font);
        }

        public void SetPaddingForAllColumns(int padding)
        {
            Columns.ForEach(x => x.Padding = padding);
        }
    }
}
